var express = require('express');
var router = express.Router();

/*视频管理*/
router.get('/ajaxdemo', function (req, res, next) {
    res.render('ajaxdemo/ajaxdemo.jsp', {title: 'ajaxdemo'});
});

router.get('/ajaxdemo/doAjax', function (req, res, next) {
    var msg = req.query;
    var firselid = msg.firselid;
    var secselid = msg.secselid;
    var group_list = msg.group_list;
    var data = {
        firselid: firselid,
        secselid: secselid,
        data: group_list
    };
    res.send(data);
});

router.post('/ajaxdemo/doAjaxPost', function (req, res, next) {
    console.log(req.body);
    res.send('请求成功');
});

router.use('/users/test', function (req, res, next) {
    mysend(req,res);
});
//router.post('/users/test', function (req, res, next) {
//    mysend(req,res);
//});
//router.get('/users/test', function (req, res, next) {
//    mysend(req,res);
//});

function mysend(req,res){
    var str_res='PHP服务器POST成功';
    if(req.method==='GET') str_res='网页GET成功';
    res.send(str_res);
}

router.post('/ajaxdemo/doForm', function (req, res, next) {
    console.log(req.body);
    console.log(req.query);
    res.send('请求成功');
});

module.exports = router;